<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/20/0020
 * Time: 16:53
 */

namespace App\Http\Controllers\Api\Admin;


use App\Http\Controllers\Api\Controller;
use App\Http\Requests\Api\JinpaiRequest;
use App\Models\Jinpai;
use App\Transformers\JinpaiTramsformer;
use Dingo\Api\Http\Request;


class JinpaisController extends Controller
{
    public function index(Request $request,Jinpai $jinpai){
        $query = $jinpai->query();
        if (!empty($request->get('goods_name'))){
            $query->where('good.goods_name','like','%' .$request->get('goods_name') . '%' );
        }
        $res = $query->paginate(20);
        return $this->response->paginator($res,new JinpaiTramsformer());


    }
    //TODO 从商品列表中点击夺宝时  自动更新到竞拍列表
/*    public function store(JinpaiRequest $request,Jinpai $jinpai){
        $jinpai->fill($request->all());
        //TODO管理员
       // $jinpai->admin_id =
        $jinpai->save();

        return $this->response->created();

    }*/
    //TODO  不使用
 /*   public function destory(Jinpai $jinpai){
        // TODO 权限
        die();
        $jinpai->delete();
        return $this->response->noContent();
    }

    public function update(JinpaiRequest $request,Jinpai $jinpai){
        //


        $jinpai->update($request->all());
        return $this->response->created();

    }*/

    public function update_one(){

    }
}